Method and associated device for filtering digital video images

ABSTRACT

The invention relates to a method for reducing visual artefacts in a frame of a digital video signal, which is coded by blocks and then decoded. A block type is defined according to the coding method for a block selected according to a predetermined set of coding types. In the method filtering is performed to reduce visual artefacts due to a block boundary. The filtering performed depends on block types of the frame in the environment of the block boundary ( 30 ).

[0001] The present invention relates to a method for reducing visualartefacts in a frame of a digital video signal, which is coded by blocksand then decoded, a block type being defined according to the codingmethod for a block selected from a predetermined set of coding types, inwhich filtering is performed to reduce visual artefacts due to a blockboundary. The present invention also relates to a device for reducingvisual artefacts in a frame of a digital video signal, which is coded byblocks and then decoded, a block type being defined according to thecoding method for a block selected according to a predetermined set ofcoding types, the device comprising a filter for reducing visualartefacts due to a block boundary. Furthermore, the present inventionrelates to a video encoder comprising means for coding and decoding adigital video signal by blocks, a block type being defined according tothe coding method for a block selected according to a predetermined setof coding types, which encoder comprises a filter for reducing visualartefacts due to a block boundary. The present invention also relates toa video decoder comprising means for reducing visual artefacts in aframe of a digital video signal, which is coded by blocks and thendecoded, a block type being defined according to the coding method for ablock selected according to a predetermined set of coding types, whichvideo decoder comprises a filter for reducing visual artefacts due to ablock boundary. The present invention also relates to a video codeccomprising means for coding and decoding a digital video signal byblocks, a block type being defined according to the coding method for ablock selected according to a predetermined set of coding types, whichvideo codec comprises a filter for reducing visual artefacts due to ablock boundary. The present invention also relates to a mobile terminalcomprising a video codec, which comprises means for coding and decodinga digital video signal by blocks, a block type being defined accordingto the coding method for a block selected according to a predeterminedset of coding types, which video codec comprises a filter for reducingvisual artefacts due to a block boundary. The present invention furtherrelates to a storage medium for storing a software program comprisingmachine executable steps for coding and decoding a digital video signalby blocks, a block type being defined according to the coding method fora block selected according to a predetermined set of coding types, forreducing visual artefacts due to a block boundary by filtering.

[0002] A transmission system like that shown in FIG. 1 is generally usedfor transferring a digital video image in compressed form. The videoimage is formed of sequential frames. In some prior art videotransmission systems, for example those according to the ITU-TH.261/H.263 recommendations, at least three frame types are defined: anI-frame (Intra), a P-frame (Predicted or Inter), and a B-frame(Bi-directional). The I-frame is generated solely on the basis ofinformation contained in the image itself, wherein at the receiving end,this I-frame can be used to form the entire image. P-frames are formedon the basis of a preceding I-frame or P-frame, wherein at the receivingstage a preceding I-frame or P-frame is correspondingly used togetherwith the received P-frame in order to reconstruct the image. In thecomposition of P-frames, for instance, motion compensation is used tocompress the quantity of information. B-frames are formed on the basisof one or more preceding P-frames or I-frames and/or one or morefollowing P- or I-frames.

[0003] The frames are further divided into blocks. One or more suchblocks forms a block region. There can generally be four differentregion types: Intra region, copy region, coded region, and not-codedregion. An intra region is a block region in which the blocks are codedindependently without reference to any other frame. A copy regionconsists of blocks which are obtained by copying the content of thereference frame into exactly the same location without any motioncompensated prediction. A coded region consists of blocks which areobtained using motion compensated prediction and prediction errorcoding. The prediction error is a difference between the pixel values ofthe actual frame and a reconstructed frame which is formed in thecoding/decoding system using motion compensated prediction, as will bedescribed in further detail later in the text. The prediction error iscoded and sent to a receiver. A not-coded region is obtained usingmotion compensated prediction only. In fact the not-coded region isequivalent to a copy region if the motion information equals 0. All theblock regions of one frame are not necessarily similar types, but oneframe can comprise block regions which are of different types.

[0004] Referring to FIG. 1, which illustrates a typical encoding anddecoding system (codec) used, for example, in the transmission ofdigital video, a current video frame to be coded comes to thetransmission system 10 as input data I_(n)(x,y). The input dataI_(n)(x,y) typically takes the form of pixel value information. In thedifferential summer 11 it is transformed into a prediction error frameE_(n)(x,y) by subtracting from it a prediction frame P_(n)(x,y) formedon the basis of a previous image. The prediction error frame is coded inblock 12 in a manner described hereinafter, and the coded predictionerror frame is directed to a multiplexer 13. To form a new predictionframe, the coded prediction error frame is also directed to a decoder14, which produces a decoded prediction error frame Ê_(n)(x,y) which issummed in a summer 15 with the prediction frame {circumflex over(P)}_(n)(x,y), resulting in a decoded frame Î_(n)(x,y). The decodedframe is saved in a frame memory 16. To code the next frame, the framesaved in the frame memory 16 is read as a reference frame R_(n)(x,y) andis transformed into a new prediction frame P_(n)(x,y) in a motioncompensation and prediction block 17, according to the formula:

P _(n)(x,y)=R _(n) [x+Dx(x,y),y+Dy(x,y)]  (1)

[0005] The pair of numbers [Dx(x,y), Dy(x,y)] is called the motionvector of the pixel at location (x,y) and the numbers Dx(x,y) andDy(x,y) are the horizontal and vertical shifts of the pixel. They arecalculated in a motion estimation block 18. The set of motion vectors[Dx(•), Dy(•)] consisting of all motion vectors related to the pixels ofthe frame to be compressed is also coded using a motion model comprisingbasis functions and coefficients. The basis functions are known to boththe encoder and the decoder. The coefficient values are coded anddirected to the multiplexer 13, which multiplexes them into the samedata stream with the coded prediction error frame for sending to areceiver. In this way the amount of information to be transmitted isdramatically reduced.

[0006] Some frames can be partly, or entirely, so difficult to predictthat it is not practical to use motion compensated prediction whencoding them. These frames or parts of frames are coded usingintra-coding without prediction, and therefore it is not necessary tosend motion vector information relating to them to the receiver.

[0007] In the receiver system 20, a demultiplexer 21 separates the codedprediction error frames and the motion information transmitted by themotion vectors and directs the coded prediction error frames to adecoder 22. The decoder 22 produces a decoded prediction error frameÊ_(n)(x,y), which is summed in a summer 23 with the prediction frameP_(n)(x,y) formed on the basis of a previous frame, resulting in adecoded frame Î_(n)(x,y). The decoded frame is directed to an output 24of the decoder and at the same time saved in a frame memory 25. Whendecoding the next frame, the frame saved in the frame memory is read asa reference frame and transformed into a new prediction frame in themotion compensation and prediction block 26, according to formula (1)presented above.

[0008] The coding method applied in block 12 to the coding of theprediction error frame or to the intra-coding of a frame or part of aP-frame to be sent without prediction, is generally based on atransformation, the most common of which is the Discrete CosineTransformation, DCT. The frame is divided into adjacent blocks having asize of e.g. 8×8 pixels. In coding and decoding, the blocks areprocessed independent of one another, The transformation is calculatedfor the block to be coded, resulting in a series of terms. Thecoefficients of these terms are quantized on a discrete scale in orderthat they can be processed digitally. Quantization causes roundingerrors, which can become visible in an image reconstructed from blocks,so that there is a discontinuity of pixel values at the boundary betweentwo adjacent blocks. Because a certain decoded frame is used forcalculating the prediction frame for subsequent predicted frames, theseerrors can be propagated in sequential frames, thus causing visibleedges in the image reproduced by the receiver. Image errors of this typeare called blocking artefacts.

[0009] Some prior art methods are known for removing blocking artefacts.These methods are characterized by the following features:

[0010] determining which pixel/pixels require value correction in orderto remove the blocking artefact,

[0011] determining a suitable low-pass filtering for each pixel to becorrected, based on the values of other pixels contained by a filteringwindow placed around the pixel,

[0012] calculating a new value for the pixel to be corrected, and

[0013] rounding the new value to the closest digitized pixel value.

[0014] Factors that influence the selection of a filter and the decisionwhether to use filtering can be, for example, the difference between thevalues of pixels across the block boundary, the size of the quantizationstep of the coefficients received as the transformation result, and thedifference of the pixel values on different sides of the pixel beingprocessed.

[0015] It has been found that prior art methods tend to remove linesthat belong to real features of the image. On the other hand, prior artmethods are not always capable of removing all blocking artefacts.

[0016] An objective of the present invention is to present a new kind offiltering arrangement for reducing blocking artefacts. The inventionalso has the objective that the method and associated device operatemore reliably and efficiently than prior art solutions.

[0017] The method according to the invention adjusts filteringparameters according to the type of blocks whose boundary is to befiltered. Different filtering parameters are chosen according to thetype of block on either side of the boundary in order to yield animproved filtering result.

[0018] The objectives of the invention are achieved by adapting theselection of pixels for filtering and the filtering process moreflexibly than before to the features of the frame and the environment ofthe filtering point and by taking into account the nature/type of theblocks to be filtered.

[0019] According to a first aspect of the invention, there is provided amethod for reducing visual artefacts in a frame that is coded by blocks,characterized in that the filtering performed on the block boundarydepends on block types of the frame in the environment of the blockboundary.

[0020] According to a second aspect of the invention, there is provideda device for implementing the method according to the invention. Thedevice according to the invention is characterized in that the filter isarranged to operate adaptively according to the block types of the framein the environment of the block boundary.

[0021] According to a third aspect of the invention, there is providedan encoder characterized in that the filter is arranged to operateadaptively according to the block types of the frame in the environmentof the block boundary,

[0022] According to a fourth aspect of the invention, there is provideda decoder characterized in that the filter is arranged to operateadaptively according to the block types of the frame in the environmentof the block boundary.

[0023] According to a fifth aspect of the invention, there is provided acodec characterized in that the filter is arranged to operate adaptivelyaccording to the block types of the frame in the environment of theblock boundary.

[0024] According to a sixth aspect of the invention, there is provided amobile terminal characterized in that the filter is arranged to operateadaptively according to the block types of the frame in the environmentof the block boundary.

[0025] According to a seventh aspect of the invention, there is provideda storage medium characterized in that the software program furthercomprises machine executable steps for filtering adaptively according tothe block types of the frame in the environment of the block boundary.

[0026] Because blocking artefacts only occur at block boundaries,according to the invention, filtering is advantageously only applied topixels at block boundaries and the vicinity thereof. Edges that are partof the image can reside anywhere in the image area. In order that onlypixels containing blocking artefacts are selected for correctivefiltering and that the quality of edges that are part of the imageitself is not affected during filtering, the following assumptions aremade;

[0027] Changes in pixel values associated with edges that are part ofthe image are generally larger than those associated with blockingartefacts, and those edges within the image, where the pixel valuechange is small, do not suffer considerably from the rounding of thepixel value difference caused by filtering.

[0028] Because the image to be coded is generally divided into blocksboth vertically and horizontally, the image contains both vertical andhorizontal block boundaries. With regard to vertical block boundaries,there are pixels to the right and left of the boundary, and with regardto horizontal block boundaries, there are pixels above and below theboundary. In general, the location of the pixels can be described asbeing on a first or a second side of the block boundary. In an exemplaryembodiment of the filtering method according to the invention, thenumber of pixels to be corrected, the characteristic features of thefilter being used and the size of the filtering window depend on thefollowing factors:

[0029] a) The type of block on either side of the boundary (e.g. inter,copy, coded, not-coded),

[0030] b) the difference in pixel values Δ across the block boundary.The difference can be defined in many ways. One definition is Δ=|r₁−I₁|, where r₁ is the value of the pixel on the first side of the blockboundary closest to the boundary, and I₁ is the value of the pixel onthe second side of the block boundary closest to the boundary,

[0031] c) the size of the quantization step QP of the coefficientsreceived as the result of the transformation used in coding, and

[0032] d) differences in pixel values between the pixels on the firstside of the block boundary, and correspondingly between the pixels onthe second side of the block boundary.

[0033] In an advantageous embodiment of the method according to theinvention, the number of the pixels selected for filtering can vary, andit is not necessarily the same on different sides of a block boundary.The number of pixels also depends on the type of block on either side ofthe boundary. Because the number of pixels is adapted to the generalfeatures of the image information contained by the frame in a particularregion according to the factors mentioned above, the method produces abetter filtering result than that provided by prior art methods. A“better” result in this context is one in which blocking artefacts arereduced to a greater extent while real edges in the image are affectedto a lesser degree. This means that a larger amount of blockingartefacts can be removed without weakening the real image edgesunreasonably.

[0034] It should be noted that in other embodiments of the invention,the factors affecting the filtering performed at a block boundary maydiffer from those presented above.

[0035] In the following, the invention will be described in more detailwith reference to the preferred embodiments and the accompanyingdrawings, in which

[0036]FIG. 1 represents a digital video encoding and decoding system(codec) according to prior art,

[0037]FIG. 2 represents the location of pixels in relation to a blockboundary in an exemplary embodiment of the method according to theinvention,

[0038]FIG. 3 represents alternatives for locating the filtering methodaccording to the invention in a digital video encoding and decodingsystem,

[0039]FIG. 4 is a schematic representation of a device for implementinga method according to the invention,

[0040]FIG. 5 represents a device according to FIG. 4 in operation, and

[0041]FIG. 6 is a schematic representation of a portable videotelecommunications device implementing a method according to theinvention.

[0042] In the above, in connection with the description of the priorart, reference was made to FIG. 1. In the following description of theinvention and its preferred embodiments, reference will be made mostlyto FIGS. 2 to 5. The same reference numbers are used for correspondingparts in the figures.

[0043]FIG. 2 shows the location of the pixels r₁-r₆ and I₁-I₆ inrelation to a vertical block boundary 30. To implement the methodaccording to the invention, certain parameters are specified. Parametern is the largest number of pixels to be examined from the block boundaryin one direction, and in the case of FIG. 2 its value is 6. It isadvantageous to select the value of the parameter n so that it has acertain relation to both the difference of the pixel values Δ across theblock boundary and to the size of the quantization step QP of thecoefficients received as the result of image coding. Furthermore, thevalue of parameter n is advantageously smaller than or equal to thenumber of pixels in the block in the direction of examination, to avoidpossible blocking artefacts associated with previous block boundariesspreading to the block boundary under examination. The followingdefinition is recommended for use in a preferred embodiment of theinvention applied to image blocks comprising 8×8 pixels: $\begin{matrix}{n = \left\{ {\begin{matrix}0 & {\Delta \quad \geq {2.00\quad \alpha}} \\1 & {{1.50\quad \alpha} \leq \Delta \quad < {2.00\quad \alpha}} \\2 & {{1.00\quad \alpha} \leq \Delta \quad < {1.50\quad \alpha}} \\3 & {{0.66\quad \alpha} \leq \Delta \quad < {1.00\quad \alpha}} \\4 & {{0.40\quad \alpha} \leq \Delta \quad < {0.66\quad \alpha}} \\5 & {{0.25\quad \alpha} \leq \Delta \quad < {0.40\quad \alpha}} \\6 & {0 \leq \Delta \quad < {0.25\quad \alpha}}\end{matrix},} \right.} & (2)\end{matrix}$

[0044] wherein α=QP−log(QP). If QP has a different value in blocks ondifferent sides of the block boundary, the smaller value of QP is usedin the calculations, as well as in all cases presented hereinafter, inwhich a definition includes reference to one OP value only. Theinvention does not place any limitations on the determination of thevalue of parameter n, but according to the guidelines of equation (2),it is advantageous that its value is generally higher when thedifference of pixel values Δ across the block boundary is small incomparison with the size of the quantization step QP of the coefficientsreceived as the result of the coding transformation. If the differencebetween the pixel values Δ is large, there is a high probability thatthere is a real image edge at the block boundary, and in this case thepixels are preferably not examined for filtering at all (n=0).

[0045] In the next step of the filtering method according to theinvention, region type information concerning the two neighbouringblocks is examined, i.e. the type of the blocks on both sides of theblock boundary in question is considered. According to the region typeinformation, the value of the parameter n may further be limited(truncated) to provide even better results for reducing blockingartefacts. The region type information is included e.g. in the codedinformation relating to the pixels of a particular block, wherein thatinformation is maintained, or temporarily stored, during decoding of theblock until a truncated value n_(tr) for parameter n is determined.

[0046] Table 1 shows truncation values according to an advantageousembodiment of the present invention. Table 1 applies in a situationwhere the maximum value of n is 6, and, of course, different truncatedvalues would be appropriate in situations where the maximum value isother than 6. The truncation values are used for the first and secondsides of the block boundary depending on the region type of the block onthe first side of the block boundary and on the region type of the blockon the second side of the block boundary. TABLE 1 type of the Block onthe First side of a type of the Block on the Second side of a boundaryboundary INTRA COPY CODED NOT_CODED INTRA n n 2 2 n 4 n 2 COPY 2 2 2 2 24 2 2 CODED 4 n 4 2 4 4 4 2 NOT_CODED 2 n 2 2 2 4 2 2

[0047] Each cell of Table 1, corresponding to a particular region typecombination, is split into two parts. The value on the left gives thetruncation value trval for the first side of the block boundary and thevalue on the right gives the truncation value trval for the second sideof the boundary. If the value of parameter n exceeds the value given inTable 1, n is truncated to the truncation value trval in Table 1. If,however, the value of the overall activity parameter n does not exceedthe value given in Table 1, the value of the parameter n (originallydetermined from equation (2)) is retained. In Table 1 the symbol “n”indicates that further truncation is not performed and the parametervalue is retained. The truncated value n_(tr) for the parameter n canalso be represented by the formula,

n _(tr)=min(trval,n),  (3)

[0048] The same table can be used both for filtering across verticalblock boundaries (horizontal filtering) by putting “Left”/“Right” inplace of “First”/“Second” and for filtering across horizontal blockboundaries (vertical filtering) by putting “Bottom”/“Up” in place of“First”/“Second”, respectively. Now, the value on the left gives thetruncation value for the pixels on the left/below the block boundary andthe value on the right gives the truncation value for the pixels on theright/above the boundary.

[0049] To further clarify the use of Table 1, an example situation ispresented in the following. In this illustrative example situation“horizontal filtering” is performed across a vertical block boundary 30Assuming that the value for parameter n, calculated from equation 2, ise.g. 4, the block on the left-hand side of the block boundary 30 inquestion is of the Intra type, and the block on the right-hand side ofthe block boundary 30 in question is of the Not-coded type, Table 1indicates that the truncation value for the left-hand side is n and thetruncation value for the right-hand side is 2. This means that the 4pixels closest to the block boundary (=the calculated value of n) areselected for examination from the left-hand side of the boundary, and 2pixels closest to the block boundary (=the truncated value of n) areselected for examination from the right-hand side.

[0050] Another example situation is presented in the following. In thisillustrative example situation “horizontal filtering” is performedacross a vertical block boundary 30. Assuming that the value ofparameter n calculated from equation (2) is e.g. 4, and the blocks onboth sides of the block boundary 30 in question are of the Copy type,Table 1 indicates that the truncation value for the left-hand side is 2and the truncation value for the right-hand side is 2. This means thatthe 2 pixels closest to the block boundary (=the truncated value of n)are selected for examination from the left-hand side of the boundary,and the 2 pixels closest to the block boundary (=the truncated value ofn) are selected for examination from the right-hand side.

[0051] For bi-directionally predicted frames (B-frames), truncation ofthe parameter n is advantageously not applied because there is no uniqueblock type information.

[0052] The next step in the filtering method according to the inventionis to determine the values of the parameters d_(l) and d_(r), whichrepresent activity, or the differences of pixel values between pixels onone side of the block boundary. A preferred definition for d_(r) is thefollowing:

[0053] d_(r)=6, if |r₁−r_(j)|≦β/j with all jε[1,6],

[0054] otherwise: d_(r)=i, where i fulfils the conditions

iε[1, n_(tr)],  (4)

[0055]  |r₁−r_(i+1)|>β/i, and

|r₁−r_(j)−<β/j with all jβ[1,i].

[0056] Here, the auxiliary parameter β=4·log(QP). The value of parameterd_(l) is determined similarly, except that all r's are replaced by l'sand the corresponding truncated value n_(tr) for the parameter n must beused, The number 6 appears in definition (4) because, according toequation (2), the highest possible value of n is 6 in this case. If n isdefined differently, but the parameters d_(r) and d_(l) are definedaccording to definition (4), the number 6 must be replaced by thehighest possible value of n according to the new definition.

[0057] It is advantageous that the values of the parameters d_(r) andd_(l) are calculated independent of one another, because the imageinformation contained by the frame can be different on different sidesof the block boundary. The invention does not limit the definition ofparameters d_(r) and d_(l), but according to the guidelines ofdefinition (4), it is advantageous that these parameters are used tolimit the blocking artefact processing relatively close to the blockboundary, if there is a real image edge near the block boundary. Theessential features of definition (4) can be summarised as follows: thevalue of parameter d_(r) (and correspondingly the value of parameterd_(l)) provides an indication of how many pixels counted from the blockboundary have approximately the same value as the pixel at the blockboundary.

[0058] A high value of parameter n (e.g. 6) indicates that thedifference between the pixel values at the block boundary is relativelysmall compared with the general variation of the pixel values within theblock. In this case, it is possible that there is a real image edge nearthe block boundary. By selecting a sufficiently small value of parameterd_(r) (or d_(l)), it is possible to restrict the filtering aimed atcorrecting blocking artefacts so that it does not have a deterioratingeffect on a real image edge close to the block boundary. In somesituations, a large number of pixels counted from the block boundaryhave approximately the same value as the pixel at the block boundary. Inthat case, definition (4) would give the parameter d_(r) (or d_(l)) arelatively high value. However, if there is a clear discontinuity inpixel values between the blocks, the parameter n has a small value andthe truncated value n_(tr) is used in the definition (4) which make surethat an unreasonably high value is not selected as the value of theparameter d_(r) (or d_(l)). Otherwise, a relatively high value of theparameter d_(r) (or d_(l)) would result in unnecessary filtering,

[0059] If blocks on both sides of the block boundary are Intra-typeblocks, the truncation has no effect on the selection of the parametervalues n, d_(r) and d_(l). On the other hand, if at least one of theblocks has a type other than Intra, the truncation of the value naccording to the formula (3) may limit the number of pixels filtered.This has the advantage that the block boundaries are not smoothed toomuch.

[0060] In addition, the largest possible number of pixels to be filteredmust be decided. This does not have a notation of its own in FIG. 2, butit can be e.g. 3, which means that filtering can only be used to correctthe value of the pixels r₁, r₂, r₃, I₁, I₂ and I₃.

[0061] When the values of the parameters n, n_(tr), d_(r) and d_(l) havebeen determined, filtering is carried out using a suitable filter. Theinvention does not limit the kind of filter that can be used, but afiltering arrangement that has been found preferable, will be describedin the following. Filtering is used to determine a new value for thepixels selected for filtering. In a preferred embodiment of theinvention, a new pixel value is determined for a given pixel bycalculating the mean of the pixel values that appear in a filteringwindow. In the preferred embodiment, the filtering window is symmetricalwith regard to the pixel to be filtered and contains, in addition to thepixel to be filtered, one, two or three pixels from both sides,depending on the values of the parameters d_(r) and d_(l) as describedhereinafter. Of course, these are only examples and other values couldbe chosen in situations where n, n_(tr), d_(r) and d_(l) are defineddifferently. The calculated mean value is rounded to the closestdigitized pixel value, whereby it becomes the new value of the filteredpixel.

[0062] Table 2 shows the determination of the width of the filteringwindow for the pixels r₁, r₂ and r₃ according to the value of parameterd_(r) in a preferred embodiment of the invention. The values of thepixels I₁, I₂ and I₃ are determined in the same manner according to thevalue of the parameter d_(l). In the table, “X” means that the pixel inquestion is not filtered at all, and the number means that the filteringwindow includes a number of pixels shown by the number from each side ofthe pixel being examined. Among other things, Table 2 shows that forfiltering to be applied to any pixel, parameters d_(r) and d_(l) mustboth have a value greater than 1. d_(r) (d_(l) > 1) r₁ r₂ r₃ 1 X X X 2 1X X 3 1 1* X 4 2 2 X 5 2 2 2** 6 3 or 2*** 3 3

[0063] The above description relates to implementing the filtering onone horizontal part of a pixel row, which is 12 pixels long and locatedsymmetrically on both sides of a vertical block boundary. Thedescription can be easily generalized to concern vertical parts of pixelcolumns, which are located symmetrically on both sides of a horizontalblock boundary: FIG. 2 can be turned 90 degrees counter-clockwise,whereby block boundary 30 becomes horizontal, and the pixels shown inthe figure form part of the vertical pixel column so that pixels r₁-r₆are the pixels above and pixels I₁-I₆ are the pixels below the boundary.To filter block boundaries throughout the whole frame, applying themethod according to the invention, all vertical block boundaries of theframe are examined row by row and all horizontal block boundaries areexamined column by column. The order has no significance as such, andthus all the horizontal block boundaries of the frame could be examinedfirst column by column, and then all the vertical block boundaries rowby row. In an advantageous embodiment of the invention, filtering isrepeated line by line, i.e. the first line of the pixels in the blocks(besides the boundary) is filtered first, then the second line, etc,

[0064]FIG. 3 shows at which points a digital image encoding and decodingsystem (codec) according to prior art can be improved by applyingfiltering according to the invention. The first alternative is to placea block implementing the filtering method according to the invention inthe output of the decoder of the receiver, as illustrated by referencenumber 31. In this case, block boundaries in the video frame arefiltered after all blocks within the frame have been decoded. Thisrequires block type information to be stored for all the blocks in oneframe. Another alternative is to place the filtering block in thereceiver before the point at which the decoded frame is directed to theframe memory 25 for forming a prediction frame, as illustrated byreference number 32. In this case, block type information for all blockswithin the frame must also be stored, as block boundary filtering isstill performed after decoding and reconstructing the entire frame.However, this alternative has the advantage that the removal of blockingartefacts also has an effect on the formation of a prediction frame,whereby blocking artefacts in one frame are not propagated via theprediction frame to subsequent frames. In order to achieve the effectjust described, the block that performs filtering according to theinvention can be placed either before or after the frame memory 25.However, the location shown by reference number 32 is preferred, becausewhen applied at this stage, the filtering influences simultaneously theframe to be output by the receiving decoder and the frame to be saved inthe memory. In the transmitter, a block implementing the filteringmethod according to the invention can be placed as shown by referencenumbers 33 and 34, either before or after the frame memory 16. In thisway, the invention can also be used to produce a corrected predictionframe at the transmission end.

[0065] In a particularly advantageous embodiment of the invention, theblock carrying out the filtering according to the invention isimplemented in a digital signal processor or a corresponding devicesuited for processing a digital signal, which can be programmed to applypredetermined processing functions to a signal received as input data.FIG. 4 presents the functional elements of a block carrying out thefiltering method according to the invention, implemented as a digitalsignal processor. Correspondingly, operation of the filtering block isillustrated by FIG. 5. Referring first to FIG. 4, the functionalelements are programmed with functional definitions (35-39) forcalculating the parameters that control the filtering method accordingto the invention. Advantageously, the functional definitions are loadedinto the signal processor in connection with its manufacture orprogramming. During operation according to FIG. 5, the frame is savedtemporarily in register 41, so that it can be processed by the signalprocessor. Processing of the frame proceeds block-by-block. At a giveninstant, a number of pixels indicated by the parameter n, n_(tr),according to the definitions provided in Table 1, are selected to beexamined 42 from each side of a certain point on a certain blockboundary, the d-parameters 43 are calculated, and filtering 44 isperformed. These operations are repeated until all boundaries of allblocks have been filtered/processed, after which the frame can be outputfrom register 41 and a new frame saved for processing. The measuresaccording to FIGS. 4 and 5 can be carried out in a separate signalprocessor or they can be implemented in a general processor which alsocontains other arrangements for signal processing.

[0066] A storage medium can be used for storing a software programcomprising machine executable steps for performing the method accordingto the invention. In an advantageous embodiment of the invention, thesoftware program is read from the storage medium to a device comprisingprogrammable means, e.g. a processor, for performing the method of theinvention.

[0067] The invention can be modified without departing from the scopedefined by the claims presented hereinafter, using the capabilities of aperson skilled in the art without actual inventive steps. For example,the parameter Δ can be calculated using the formula Δ=|(r₁+r₂)−(I₁+I₂)|or some other formula considered suitable. The definitions of the otherparameters presented above should also be considered as examples only. Aparticularly advantageous use of the invention is in mobile videotelecommunication applications, digital television receivers and otherdevices that at least receive and decode digital video image. It shouldfurther be noted that in general the method according to the inventionmay be applied to any image coding method in which an image isencoded/decoded on a block-by-block basis, including individual (i.e.still) digital images.

[0068]FIG. 6 shows a mobile terminal 46 intended for use as a portablevideo telecommunications device and applying the method according to theinvention. Advantageously, the mobile terminal 46 comprises at leastdisplay means 47 for displaying images, audio means 48 for capturing andreproducing audio information, a keyboard 49 for inputting e.g. usercommands, a radio part 50 for communicating with a mobile communicationsnetwork (not shown), processing means 51 for controlling the operationof the device, memory means 52 for storing information, and preferably acamera 53 for taking images.

[0069] The present invention is not solely restricted to the abovepresented embodiments, but it can be modified within the scope of theappended claims.

1. A method for reducing visual artefacts in a frame of a digital videosignal, which is coded by blocks and then decoded, a block type beingdefined according to the coding method for a block selected from apredetermined set of coding types, in which filtering is performed toreduce visual artefacts due to a block boundary, characterized in thatthe filtering performed on the block boundary depends on block types ofthe frame in the environment of the block boundary (30).
 2. A methodaccording to claim 1 , characterized in that the frame comprises atleast one region of blocks, each block within said region having aregion type, and that the filtering performed on the block boundarydepends on a region type of the blocks in the environment of the blockboundary (30).
 3. A method according to claim 1 , characterised in thatthe filtering performed on the block boundary depends on a block type ofa block on a first side of the block boundary (30) and on a block typeof a block on a second side of the block boundary (30).
 4. A methodaccording to claim 1 , characterised in that at least one parameter ofthe filtering performed to reduce visual artefacts due to a blockboundary on at least one side of the block boundary is modifiedaccording to the block type of at least one block in the environment ofthe block boundary (30).
 5. A method according to claim 4 ,characterised in that at least one parameter of the filtering performedto reduce visual artefacts due to a block boundary is modified accordingto the block type of a first block and a second block, the first andsecond block being located on opposite sides of the block boundary (30).6. A method according to claim 4 , characterised in that said at leastone parameter is selected from a group comprising; a number of pixels tobe examined, a number of pixels to be filtered, an activity measureproviding an indication of the difference between pixel values on oneside of the block boundary, a filtering window.
 7. A method according toclaim 1 , in which a number of pixels (n) is selected for examinationfrom at least one side of the block boundary (30), characterized in thatthe number of pixels (n) selected for examination depends on the imagecontent of the frame in the environment of the block boundary (30), andthat the number of pixels (n) selected for examination further dependson the block type of a block in the environment of the block boundary(30).
 8. A method according to claim 7 , characterised in that thenumber of pixels (n) selected for examination depends on the differencein pixel value (Δ) between pixels across the block boundary.
 9. A methodaccording to claim 7 , characterized in that the number of pixelsselected for examination depends on the size of the quantization step(QP) of the coefficients used in the coding of the blocks.
 10. A methodaccording to claim 9 , characterized in that the number of pixels (n)selected for examination is determined by the formula; $\begin{matrix}{n = \left\{ {\begin{matrix}0 & {\Delta \quad \geq {2.00\quad \alpha}} \\1 & {{1.50\quad \alpha} \leq \Delta \quad < {2.00\quad \alpha}} \\2 & {{1.00\quad \alpha} \leq \Delta \quad < {1.50\quad \alpha}} \\3 & {{0.66\quad \alpha} \leq \Delta \quad < {1.00\quad \alpha}} \\4 & {{0.40\quad \alpha} \leq \Delta \quad < {0.66\quad \alpha}} \\5 & {{0.25\quad \alpha} \leq \Delta \quad < {0.40\quad \alpha}} \\6 & {0 \leq \Delta \quad < {0.25\quad \alpha}}\end{matrix},} \right.} & (2)\end{matrix}$

wherein Δ is the difference in value between pixels across the blockboundary, α=QP·log(QP) and QP is the size of the quantization step ofthe coefficients used in the coding of the blocks.
 11. A methodaccording to claim 8 , characterized in that the number of pixels (n) isfirst defined according to the image content of the frame in theenvironment of the block boundary (30), and the number of pixels (n) isfurther truncated according to the block type of a block in theenvironment of the block boundary (30) to give a truncated number ofpixels (n_(tr)) for examination.
 12. A method according to claim 11 ,characterized in that the truncated number of pixels (n_(tr)) isdetermined by selecting a truncation value (trval) according to thetable Region type of the Block on the First Region type of the Block onthe Second side side INTRA COPY CODED NOT_CODED INTRA n n 2 2 n 4 n 2COPY 2 2 2 2 2 4 2 2 CODED 4 n 4 2 4 4 4 2 NOT_CODED 2 n 2 2 2 4 2 2

and using said selected truncation value (trval) with the formula n_(tr)=Min(trval,n),  (3).
 13. A method according to claim 1 ,characterized in that certain pixels to be filtered are selected, and anew value is determined for each pixel to be filtered on the basis ofpixels that appear in a filtering window set around the pixel.
 14. Amethod according to claim 1 , characterized in that pixels to befiltered are selected from the pixels selected for examination.
 15. Amethod according to claim 13 , characterized in that the new value ofthe pixel to be filtered is the mean value of the pixels that appear inthe filtering window.
 16. A method according to claim 13 , characterizedin that for determining a new value for the pixels to be filtered on thefirst side of the block boundary, said filtering window is used, and thesize of the window is determined according to the table d_(r)(d_(l) > 1) r₁ r₂ r₃ 1 X X X 2 1 X X 3 1 1* X 4 2 2 X 5 2 2 2** 6 3 or2*** 3 3

wherein an integer parameter d_(r) indicates activity on the first sideof the block boundary, and an integer parameter d_(l) indicates activityon the second side of the block boundary, r₁, r₂ and r₃ are the threepixels on the first side of the block boundary closest to the boundaryin this order, X means that the pixel is not filtered, the number meansthat in addition to the pixel to be filtered, a quantity of pixels shownby the number are taken to the filtering window from both sides of thepixel to be filtered, and “3 or 2” means “3, if d_(l)>2, otherwise 2”,and for determining the new value of the pixels to be filtered on theother side of the block boundary, a filtering window defined similarlyis used, with the exception that all r's are replaced by l's and viceversa.
 17. A method according to claim 16 , characterized in that saidactivity is determined on the basis of changes in pixel values.
 18. Amethod according to claim 16 , characterized in that d_(r)=6, if|r₁−r_(j)|≦β/j with all jε[1,6], otherwise: d_(r)=i, where i meets theconditions iε[1,n_(tr)], |r ₁ −r _(i+1) |>β/i, and |r ₁ −r _(j) |≦β/jwith all jε[1,i], wherein the auxiliary parameter β=4·log(QP) and QP isthe size of the quantization step of the coefficients used in the codingof the blocks, and the value of the parameter d_(l) is determinedsimilarly, with the exception that all r's are replaced by l's.
 19. Adevice for reducing visual artefacts in a frame of a digital videosignal, which is coded by blocks and then decoded, a block type beingdefined according to the coding method for a block selected according toa predetermined set of coding types, the device comprising a filter forreducing visual artefacts due to a block boundary, characterized in thatthe filter is arranged to operate adaptively according to the blocktypes of the frame in the environment of the block boundary (30).
 20. Adevice according to claim 19 , characterised in that the filter isarranged such that the frame comprises at least one region of blocks,each block within said region having a region type, and that thefiltering performed on the block boundary depends on a region type ofthe blocks in the environment of the block boundary (30).
 21. A deviceaccording to claim 19 , characterised in that the filter is arrangedsuch that the filtering performed on the block boundary depends on ablock type of a block on a first side of the block boundary (30) and ona block type of a block on a second side of the block boundary (30). 22.A device according to claim 19 , characterised in that the filter isarranged such that at least one parameter of the filtering performed toreduce visual artefacts due to a block boundary on at least one side ofthe block boundary is modified according to the block type of at leastone block in the environment of the block boundary (30).
 23. A deviceaccording to claim 22 , characterised in that the filter is arrangedsuch that at least one parameter of the filtering performed to reducevisual artefacts due to a block boundary is modified according to theblock type of a first block and a second block, the first and secondblock being located on opposite sides of the block boundary (30).
 24. Adevice according to claim 22 , characterised in that said at least oneparameter is selected from a group comprising: a number of pixels to beexamined, a number of pixels to be filtered, an activity measureproviding an indication of the difference between pixel values on oneside of the block boundary, a filtering window.
 25. A device accordingto claim 21 , characterized in that it comprises means (42) that operateadaptively according to the image content of the frame, for selecting anumber of pixels (n) for examination, and that means (42) for selectinga number of pixels (n) for examination comprises further means (42) forexamining the block type of a block in the environment of the blockboundary (30).
 26. A device according to claim 25 , characterised inthat it comprises means (42) for selecting the number of pixels (n) forexamination depending on the difference in pixel value (Δ) betweenpixels across the block boundary.
 27. A device according to claim 19 ,characterized in that it comprises means (42) for selecting a number ofpixels (n) for examination depending on the size of the quantizationstep (QP) of the coefficients used in the coding of the blocks.
 28. Adevice according to claim 27 , characterized in that the means (42) forselecting the number of pixels (n) for examination comprises means (35)for determining said number of pixels according to the formula:$\begin{matrix}{n = \left\{ {\begin{matrix}0 & {\Delta \quad \geq {2.00\quad \alpha}} \\1 & {{1.50\quad \alpha} \leq \Delta \quad < {2.00\quad \alpha}} \\2 & {{1.00\quad \alpha} \leq \Delta \quad < {1.50\quad \alpha}} \\3 & {{0.66\quad \alpha} \leq \Delta \quad < {1.00\quad \alpha}} \\4 & {{0.40\quad \alpha} \leq \Delta \quad < {0.66\quad \alpha}} \\5 & {{0.25\quad \alpha} \leq \Delta \quad < {0.40\quad \alpha}} \\6 & {0 \leq \Delta \quad < {0.25\quad \alpha}}\end{matrix},} \right.} & (2)\end{matrix}$

wherein Δ is the difference in value between pixels across the blockboundary, α=QP·log(QP) and OP is the size of the quantization step ofthe coefficients used in the coding of the blocks.
 29. A deviceaccording to claim 19 , characterized in that it comprises means (42)for truncating the number of pixels (n) selected for examination on thebasis of the block type of a block in the environment of the blockboundary.
 30. A device according to claim 19 , characterized in that themeans (42) for selecting a number of pixels for examination comprisesmeans for defining the number of pixels (n) according to the imagecontent of the frame in the environment of the block boundary (30), andmeans for truncating the number of pixels (n) according to the blocktype of a block in the environment of the block boundary (30).
 31. Adevice according to claim 30 , characterized in that the means fortruncating the number of pixels (n) comprises means for selecting atruncation value (trval) according to the table: Type of the Block onthe Type of the Block on the Second side First side INTRA COPY CODEDNOT_CODED INTRA n n 2 2 n 4 n 2 COPY 2 2 2 2 2 4 2 2 CODED 4 n 4 2 4 4 42 NOT_CODED 2 n 2 2 2 4 2 2

and using said selected truncation value (trval) with the formula: n_(tr)=min(trval,n),  (3).
 32. A device according to claim 19 ,characterized in that it comprises means (42) for selecting certainpixels to be filtered, means (42) for defining a filtering window, andmeans for determining a new value for each pixel to be filtered on thebasis of pixels that appear in a filtering window set around the pixel.33. A device according to claim 32 , characterized in that the means fordetermining a new value for each pixel comprises means for calculating amean value of the pixels that appear in the filtering window.
 34. Adevice according to claim 28 , characterized in that the means fordetermining a new value for each pixel comprises means for using saidfiltering window for the pixels to be filtered on the first side of theblock boundary, and means for determining the size of the windowaccording to the table d_(r) (d_(l) > 1) r₁ r₂ r₃ 1 X X X 2 1 X X 3 1 1*X 4 2 2 X 5 2 2 2** 6 3 or 2*** 3 3

wherein an integer parameter d_(r) indicates activity on the first sideof the block boundary, and an integer parameter d_(l) indicates activityon the second side of the block boundary, r₁, r₂ and r₃ are the threepixels on the first side of the block boundary closest to the boundaryin this order, X means that the pixel is not filtered, the number meansthat in addition to the pixel to be filtered, a quantity of pixels shownby the number are taken to the filtering window from both sides of thepixel to be filtered, and “3 or 2” means “3, if d_(l)>2, otherwise 2”,and means for using a filtering window defined similarly for determiningthe new value of the pixels to be filtered on the other side of theblock boundary, with the exception that all r's are replaced by l's andvice versa.
 35. A device according to claim 34 , characterized in thatd_(r)=6, if |r₁−r_(l)|≦β/j with all jε[1,6], otherwise: d_(r)=i, where imeet the conditions iε[1,n_(tr)], |r ₁ −r _(i+1) |>β/i, and |r ₁ −r _(j)|≦β/j with all jε[1,i], wherein the auxiliary parameter β=4·log(QP) andOP is the size of the quantization step of the transformationcoefficients used in transformation coding of the blocks, and the valueof the parameter d_(l) being determined similarly, with the exceptionthat all r's are replaced by l's.
 36. A device according to claim 19 ,characterized in that it comprises programmable means (42) for selectingpixels from a saved frame as the pixels to be examined, programmablemeans (45) for selecting pixels to be filtered from among the pixels tobe examined, and programmable means (44) for determining the new valueof the pixels to be filtered.
 37. A video encoder (10) comprising means(35-44) for coding and means for decoding a digital video signal byblocks, a block type being defined according to the coding method for ablock selected according to a predetermined set of coding types, whichencoder comprises a filter for reducing visual artefacts due to a blockboundary, characterized in that the filter is arranged to operateadaptively according to the block types of the frame in the environmentof the block boundary (30).
 38. A video decoder (20) comprising means(35-44) for reducing visual artefacts in a frame of a digital videosignal, which is coded by blocks and then decoded, a block type beingdefined according to the coding method for a block selected according toa predetermined set of coding types, which video decoder comprises afilter for reducing visual artefacts due to a block boundary,characterized in that the filter is arranged to operate adaptivelyaccording to the block types of the frame in the environment of theblock boundary (30).
 39. A video codec (10, 20) comprising means (35-44)for coding and decoding a digital video signal by blocks, a block typebeing defined according to the coding method for a block selectedaccording to a predetermined set of coding types, which video codeccomprises a filter for reducing visual artefacts due to a blockboundary, characterized in that the filter is arranged to operateadaptively according to the the block types of the frame in theenvironment of the block boundary (30).
 40. A mobile terminal (46)comprising a video codec (10, 20), which comprises means (35-44) forcoding and decoding a digital video signal by blocks, a block type beingdefined according to the coding method for a block selected according toa predetermined set of coding types, which video codec comprises afilter for reducing visual artefacts due to a block boundary,characterized in that the filter is arranged to operate adaptivelyaccording to the the block types of the frame in the environment of theblock boundary (30).
 41. A storage medium for storing a software programcomprising machine executable steps for coding and decoding a digitalvideo signal by blocks, a block type being defined according to thecoding method for a block selected according to a predetermined set ofcoding types, for reducing visual artefacts due to a block boundary byfiltering, characterized in that the software program further comprisesmachine executable steps for filtering adaptively according to the theblock types of the frame in the environment of the block boundary (30).